/**
 * ServiceRegistry.java
 */
package fss.remote;

import java.rmi.Remote;
import java.rmi.RemoteException;

import fss.common.communication.Request;
import fss.util.rmi.RmiId;
import java.util.Set;

/**
 * A remote interface that registers service(s).
 * <p>
 * This is the observable/publisher that <code>RemoteService</code> objects
 * will registers their service.
 * 
 * @author thinh
 *
 */
public interface ServiceRegistry extends Remote {
    /**
     * Get the identifier for this remote object.
     * @return the id.
     * @throws RemoteException remote invocation error.
     */
    public RmiId getId() throws RemoteException;
    /**
     * Register a remote service (object).
     * <p>
     * This is similar to <code>Obserable.addObserver</code> method.
     * @param service the remote service.
     * @throws RemoteException remote invocation error.
     */
    public void register(RemoteService service) throws RemoteException;
    /**
     * Process a request.
     * <p>
     * When a request comes, the registry will try to notify its observer(s) that a
     * request came. Only the observers/subscribes will process the request.
     * @param request the request object.
     * @throws RemoteException remote invocation error.
     */
    public void processRequest(Request request) throws RemoteException;
    /**
     * Get a set of registered service identifiers (no duplicates).
     * @return a set of registration identifiers.
     * @throws RemoteException error invoking the method.
     */
    public Set<RmiId> getRegisteredServiceList() throws RemoteException;
    /**
     * This stop the service registry and notify all of its registered 
     * service(s) that it went down.
     * <p>
     * This method intends to simulate a 'clean' or scheduled termination
     * of the service registry.
     * @throws RemoteException remote invocation error.
     */
    public void stop() throws RemoteException;
    /**
     * Start this service.
     * @throws RemoteException error communicating with remote object.
     */
    public void start() throws RemoteException;
}
